package com.zxd.dao;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.zxd.model.Employee;

@Repository("employeeDao")
public class EmployeeDao implements IEmployeeDao {
	
	private SessionFactory sessionFactory; 
	
	protected Session getSession(){
		return sessionFactory.getCurrentSession();
	}

	@Resource
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	
	@Override
	public Employee add(Employee employee) {
		this.getSession().save(employee);
		return employee;
	}
}
